/**
 * Created by jiangtao on 16/6/17.
 */
define(function(require, exports, module) {
   require("LIBS/mockjs/mock.js");
   require("LIBS/iscroll/iscroll-probe.js");
   var me = {
      layout:require("TEMPLATE/common/layout.tpl"),
      element: document.getElementById('app'),
      template: require("TEMPLATE/activity/list.tpl"),
      VM:null,
      activeIndex:1,
      init: function(){
         var use = ["render","run","event"];
         use.forEach(function(name){
            for(var key in this) {
               if(key == name) {
                  this[key]();
               };
            };
         }.bind(this));
      },
      render: function(){
         this.VM = layout(this.element,{
            layout:this.layout,
            template:this.template
         });
      },
      run: function(){
         var vm   = this.VM,
             self = this;
         //分页
         Pagination("#scroll_el",function(d,iscroll,to){
            console.log(to)
         });
         //监听数据变化
         vm.$watch('activeList.data',function(){

         });
         vm.handel.text = "发布活动";
         vm.handel.url  = staticUrl + "/views/index.html?entery=activity/addActivity"
         var mock = Mock.mock(
             {"array|10-100": [{
                id:2,
                user:{
                   nickName:"宝宝爱吃鱼",
                   avatar:"../images/head2.jpg"
                },
                detail:{
                   title:"和名师学习插❀",
                   startTime:"2016年6月29日",
                   address:"成都市青羊区十二桥路",
                   imgUrl:"http://docs.ebdoor.com/image/productimage/0/592/5929211_1.jpg",
                   detail_text:"插花(floarr)，亦可称为插花艺术（ikebana），就是把花插在瓶、盘、" +
                   "盆等容器里，而不是栽在这些容器中。所插的花材，或枝、或花、或叶，均不带根，只是植物体上的一部分" +
                   "，并且不是随便乱插的，而是根据一定的构思来选材，遵循一定的创作法则，插成一个优美的形体（造型）" +
                   "，借此表达一种主题，传递一种感情和情趣，使人看后赏心悦目，获得精神上的美感和愉快。中国插花是一" +
                   "种古老的汉族文化现象，大多为满足主观与情感的需求，亦是日常生活进行娱乐的特殊方式。插花源于古代汉族" +
                   "民间的爱花、种花、赏花、摘花、赠花、佩花、簪花。"
                }
             }
             ]}).array;
         var tableData = [
            {name:'定制辅导',data:[],url:staticUrl + '/views/index.html?entery=teacher/index'},
            {name:'精品课程',data:mock,url:staticUrl + '/src/views/index.html?entery=activity/list'},
            {name:'优质岗位',data:[],url:staticUrl + '/views/index.html?entery=position/position'}
         ];
         vm.nav = tableData;
         vm.nav[this.activeIndex].active = true;
         vm.activeList.data = tableData[this.activeIndex].data;
      },
      event:function(){
          var vm = this.VM;
          vm.goto = function(){
             location.href = staticUrl + "/views/index.html?entery=activity/activityDetail"
          }
      }
   }
   me.init();
});